// 模拟 lodash 中的 curry 方法
function getSum(a, b, c) {
    return a + b + c;
}

function curry(fn) {
    return function curriedFn(...args) {
        // 判断实参和形参的个数
        if (args.length < fn.length) {
            return function (...rest) {
                return curriedFn(...args, ...rest);
            };
        }
        return fn(...args);
    };
}

const curried = curry(getSum);

console.log(curried(1, 2, 3));
console.log(curried(1)(2, 3));
console.log(curried(1, 2)(3));
